import java.util.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Scanner;

public class Solution {
    public int maxSubArray(int[] nums) {
        if (nums == null || nums.length == 0) {
            throw new IllegalArgumentException("数组不能为空");
        }

        int maxSum = nums[0];   // 全局最大和
        int currentSum = nums[0]; // 当前子数组最大和

        for (int i = 1; i < nums.length; i++) {
            // 如果当前子数组和小于0，则从当前元素重新开始
            currentSum = Math.max(nums[i], currentSum + nums[i]);
            // 更新全局最大和
            maxSum = Math.max(maxSum, currentSum);
        }

        return maxSum;
    }

public static void main(String[] args) {
    if (args.length >= 1) {
        String input = args[0].trim();
        if (input.startsWith("[") && input.endsWith("]")) {
            input = input.substring(1, input.length() - 1);
        }
        
        String[] numStrs = input.split(",");
        int[] nums = new int[numStrs.length];
        for (int i = 0; i < numStrs.length; i++) {
            nums[i] = Integer.parseInt(numStrs[i].trim());
        }
        
        Solution solution = new Solution();
        int result = solution.maxSubArray(nums);
        System.out.println(result);
    }
}
}